package captor.windowsystem.formcomponent.aop.abstractpointcutpanel;

import java.awt.event.KeyEvent;

import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.table.TableModel;

import captor.modelsystem.Model;
import captor.modelsystem.Project;

public class KeyListenTable extends JTable{
	
	/**
	 * This class sets the model status when data inside are update by key press.
	 * 
	 * @author Carlos Alberto
	 */
	private static final long serialVersionUID = 8547357515193794056L;

	private final Model model;
	

	public KeyListenTable(TableModel tableModel, Model captorModel){
		super(tableModel);
		this.model = captorModel;
	}
	
	@Override
	protected boolean processKeyBinding(KeyStroke stroke, KeyEvent evt, int condition, boolean pressed) {
	 
		if (evt.getID() == KeyEvent.KEY_RELEASED){
			model.getProject().setStatus(Project.UNSAVED);
		}
		else{
			return super.processKeyBinding(stroke, evt, condition, pressed);
		}
		return true;
	}
}

